# add java (.java, and .class), and antlr (.g, and .tokens) extensions
# to the list of known file extentions
.SUFFIXES: .java .class .g

# generic 
JC = javac
JVM = java
JAR = jar
CLASSPATH = .
JFLAGS = -classpath $(CLASSPATH)

# compile a .java file into one or more .class files
.java.class:
	$(JC) $(JFLAGS) $<


JAVA_SOURCES = Cell.java \
               Wrapper.java \
               KDefinition.java \
               MaudeTerm.java \
               DefaultTerm.java \
               NestedTerm.java \
               KTreeNode.java \
               MaudeSAXHandler.java \
               TextViewer.java \
               VisualViewer.java
CLASSES = $(JAVA_SOURCES:.java=.class)
VIEWER_JAR = matchCviewer.jar
MAIN = Viewer


# targets
# default target is all
all: build

# build target
build: $(VIEWER_JAR)

# build a jar
$(VIEWER_JAR): $(CLASSES)
	$(JAR) -cf $@ *.class

# run target (depends on build)
run: build
	$(JVM) $(JFLAGS) TextViewer tmp.xml tmp.kfg

# clean target removes the .class files and the files generated by antlr
clean:
	rm -rf $(VIEWER_JAR) *.class

